<template>
    <div>
        <div class="headerSty1" style="margin: 20px 0 10px;">
            <div class="headerLeftSty">
                <div class="textSty">资金支付</div>
            </div>
            <div>
                <el-form>
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="" label-width="10px">
                                <el-table :data="payList" style="width: 100%">
                                    <el-table-column type="index" label="序号" align="center" />
                                    <el-table-column prop="planName" label="计划名称" align="center" />
                                    <el-table-column prop="paymentRatio" label="付款比例(%)" align="center" />
                                    <el-table-column prop="paymentAmount" label="付款金额" align="center" />
                                    <el-table-column prop="amountPaid" label="已付金额(元)" align="center" />
                                    <el-table-column label="状态" align="center">
                                        <template slot-scope="scope">
                                            {{ scope.row.amountPaid >= scope.row.paymentAmount ? '已结清' : '未结清' }}
                                        </template>
                                    </el-table-column>
                                    <el-table-column prop="remark" label="备注" align="center" />
                                    <el-table-column label="操作" align="center">
                                        <template slot-scope="scope">
                                            <el-button size="mini" type="text" @click="handlePaymentOne(scope.row)"
                                                v-if="scope.row.amountPaid < scope.row.paymentAmount">付款</el-button>
                                            <el-button size="mini" type="text"
                                                @click="handlePaymentTwo(scope.row.id, scope.row)">付款记录</el-button>
                                        </template>
                                    </el-table-column>
                                </el-table>
                            </el-form-item>

                        </el-col>
                        <el-col :span="24">
                            <el-form-item label-width="40px">
                                <el-button type="primary" @click="historyBtnSub">下一步</el-button>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-form>
            </div>
        </div>
        <paymentOne v-if="paymentOneVisible" ref="paymentOne" @refreshPaymentOne="refreshPaymentOne" />
        <paymentTwo v-if="paymentTwoVisible" ref="paymentTwo" @refreshPaymentTwo="refreshPaymentTwo" @getList="getList" />
        <paymentTwoList v-if="paymentTwoListVisible" ref="paymentTwoList" @refreshPaymentOne="refreshPaymentOne" />
    </div>
</template>
<script>
import paymentOne from './paymentOne.vue';
import paymentTwo from './paymentTwo.vue';

import paymentTwoList from './paymentTwoList.vue';
import { getPaymentList } from "@/api/contract/contractOrg";
export default {
    components: { paymentOne, paymentTwo, paymentTwoList },
    props: {
        dataForm: {
            type: Object,
            default: {},
        }
    },
    data() {
        return {
            form: {},
            // 表单校验
            rules: {},
            paymentOneVisible: false,
            paymentTwoVisible: false,
            paymentTwoListVisible: false,
            tableData: [],
            reverse: true,
            activities: [{
                content: '活动按期开始',
                timestamp: '2018-04-15'
            }, {
                content: '通过审核',
                timestamp: '2018-04-13'
            }, {
                content: '创建成功',
                timestamp: '2018-04-11'
            }],
            payList: []

        }
    },
    created() {
        this.getList()
    },
    methods: {
        getList() {
            // 查询合同付款列表
            getPaymentList(this.dataForm.id).then(res => {
                this.payList = res.rows
            })
        },
        // 付款
        handlePaymentOne(row) {
            this.paymentOneVisible = true;
            this.$nextTick(() => {
                this.$refs.paymentOne.init(row);
            });
        },
        // 付款记录
        handlePaymentTwo(id, row) {
            this.paymentTwoVisible = true;
            this.$nextTick(() => {
                this.$refs.paymentTwo.init(id, row);
            });
        },
        // 刷新页面
        refreshPaymentOne() {
            this.paymentOneVisible = false;
            this.paymentTwoListVisible = false;
            this.$nextTick(() => {
                this.getList()
            });
        },
        // 付款记录修改
        refreshPaymentTwo(form, list) {
            this.paymentTwoVisible = false;
            setTimeout(() => {
                this.paymentTwoListVisible = true;
                this.$nextTick(() => {
                    this.$refs.paymentTwoList.init(form, list);
                });
            }, 0);
        },
        // 提交
        historyBtnSub() {
            this.form.status = this.form.status > 8 ? this.form.status : 9
            this.$nextTick(() => {
                this.$emit('refreshSignature', { ...this.dataForm, ...this.form })
            })

        }
    },
}

</script>

<style lang="scss" scoped>
.headerSty {
    display: flex;
    justify-content: space-between;
    width: 97%;

    .headerLeftSty {
        display: flex;
        align-items: center;

        .textSty {
            margin-left: 8px;
            font-size: 16px;
            font-weight: 700;
        }


    }

}

.headerSty1 {
    width: 97%;

    .headerLeftSty {
        display: flex;
        align-items: center;

        .textSty1 {
            margin-left: 8px;
            font-size: 14px;
            font-weight: 700;
        }

        .textSty {
            margin-left: 8px;
            font-size: 16px;
            font-weight: 600;
        }
    }

}

.navSty {
    height: 15px;
    width: 5px;
    background: rgb(90, 156, 248);
}


.contSty {
    display: flex;

    .contLeftSty {
        height: 80px;
        width: 5px;
        background: rgb(90, 156, 248);
    }

    .allBlo {
        margin-left: 5px;
    }

    .LastBlockSty {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 132px;
        height: 30px;
        background: white;
        border-radius: 5px;
        color: rgb(90, 156, 248);
        border: 1px solid rgb(90, 156, 248);

        .el-icon-warning {
            color: rgb(90, 156, 248);
            font-weight: bolder;
            margin-right: 5px;
            font-size: 18px;
        }
    }

    .blockSty {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 132px;
        height: 30px;
        background: rgb(90, 156, 248);
        border-radius: 5px;
        color: white;

        .el-icon-check {
            color: white;
            font-weight: bolder;
            margin-right: 5px;
            font-size: 18px;
        }

        .el-icon-close {
            color: white;
            font-weight: bolder;
            margin-right: 5px;
            font-size: 18px;
        }
    }

    .lastTeSty {
        flex: 1;
        height: 120px;
        background: white;
        margin-left: 10px;
        border-radius: 5px;
        border: 1px solid rgb(90, 156, 248);
        overflow-y: auto;
    }
}

.text1 {
    font-size: 14px;
    font-weight: 500;
}

.text2 {
    font-size: 14px;
    color: #999;
}

.el-icon-arrow-right {
    color: rgb(90, 156, 248);
    font-weight: bolder;
    margin: 0 10px;
    font-size: 32px;
}
</style>